package com.msgqer.rchat.message;

import java.util.Date;

import com.msgqer.rchat.client.Client;

/**
 * 消息对象
 * 
 * @author keaizhuzhu@公众号：面试怪圈；官网地址：{@link http://www.mianshiguaiquan.com}
 *         这里有更多面试、技术、学习资料及源码等
 */
public class MessageDto {

	private String content;
	private String clientName;
	private String clientId;
	private String clientHeader;
	private Date sendTime;
	/**
	 * 是否是自己的消息
	 */
	private Integer isYourself;

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public String getClientName() {
		return clientName;
	}

	public void setClientName(String clientName) {
		this.clientName = clientName;
	}

	public String getClientHeader() {
		return clientHeader;
	}

	public void setClientHeader(String clientHeader) {
		this.clientHeader = clientHeader;
	}

	


	public Integer getIsYourself() {
		return isYourself;
	}

	public void setIsYourself(Integer isYourself) {
		this.isYourself = isYourself;
	}

	public String getClientId() {
		return clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	/**
	 * 生成发送给客户端的消息dto
	 * 
	 * @param client
	 * @param messageContent
	 * @return
	 */
	public static MessageDto newMessageDto(Client client, String messageContent) {
		MessageDto messageDto = new MessageDto();
		messageDto.setClientId(client.getClientId());
		messageDto.setClientHeader(client.getClientHeader());
		messageDto.setClientName(client.getClientName());
		messageDto.setContent(messageContent);
		messageDto.setSendTime(new Date());
		return messageDto;
	}

	@Override
	public String toString() {
		return "MessageDto [content=" + content + ", clientName=" + clientName + ", clientHeader=" + clientHeader
				+ ", sendTime=" + sendTime + "]";
	}

}
